#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>

int num=0;
int main()
{
    // int num=0;
    pid_t child_pid;
    child_pid=vfork();
    if(child_pid < 0)
        printf("create exe fail!\n");
    if(child_pid == 0)
    {
        while(1)
        {
            for(int i=0;i<3;i++)
            {
                num++;
                printf("this is a child process num:%d!\n",num);
                sleep(3);
            }
            exit(2);
        }

    }
    else
    {
        while(1)
        {
            printf("this is a parent process num:%d!\n",num);
            sleep(3);
        }
    }
    
    return 0;
}